<?php
/*
Aclass_acan_tat:多应用关联模块

Acan框架数据function
	2010-08-01
	www.abans.cn
	abans@qq.com
*/

class Aclass_acan_tat{
	function  __construct() {
	}
	//tat
	function tatall($key,$val){
	//	$sql = "SELECT * FROM ".Acan_table_acan_tat_name."WHERE name ='$key'";
	//	$model = Afun_db()->query($sql)-fetchAll();
	//	print_r($model);
		if(!empty($num)){
			$limit = " LIMIT 0,$num";
		}
		$by = " GROUP BY b.app ";
	echo	$sql = "SELECT a.*,b.name FROM ".Acan_table_acan_tat." a,".Acan_table_acan_tat_name." b WHERE b.key='$key' and (a.keya = b.app and a.vala ='$val') or (a.keyb = b.app and a.valb ='$val')".$by.$limit;
		$model = Afun_db()->query($sql)->fetchAll();
		print_r($model);
	}
	function tat($keya,$vala,$num=''){
	//	$sql = "SELECT * FROM ".Acan_table_acan_tat_name."WHERE name ='$key'";
	//	$model = Afun_db()->query($sql)->fetchAll();
	//	print_r($model);
		echo $tat = $this->findtat('blog');
		foreach($tat as $k=>$v){
			if(empty($tat_v))
				$tat_v = '='.$v['tat'];
			else
				$tat_v = ','.$v['tat'];
		}
		
		if(!empty($num)){
			$limit = " LIMIT 0,$num";
		}
	//	$by = " GROUP BY b.app ";
	echo	$sql = "SELECT a.*,b.name FROM ".Acan_table_acan_tat." a,".Acan_table_acan_tat_name." b WHERE b.key='$key' and (a.keya = b.app and a.keyb= and a.vala ='$val') or (a.keyb = b.app and a.valb ='$val')".$by.$limit;
		$model = Afun_db()->query($sql)->fetchAll();
		//print_r($model);
	}
	function findtat($app){
		$sql = "SELECT id,tat FROM ".Acan_table_acan_tat_key." WHERE app1 ='$app' or  app2 ='$app'";
		$model = Afun_db()->query($sql)->fetchAll();
		print_r($model);
	}
}
?>